Skip to content

Majority Element ​

Majority Element — LeetCode

Find the element that appears more than n/2 times in the array.

Approach ​

Approach 1: Use a hashmap to count, when count = n/2

Approach 2: Moore's Voting Algorithm > Single Pass Moore's Algorithm

Remarks ​